/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "lcd.h"
#include "lvgl.h"
#include "lv_port_disp_template.h"
#include "ui.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
uint16_t get_x(uint16_t a);

uint16_t get_y(uint16_t a);

void light_left_show_color(uint32_t color);

void light_right_show_color(uint32_t color);

void light_left_show_color_with_emergency(uint32_t color);

void light_right_show_color_with_emergency(uint32_t color);

void show_num_left(uint8_t show_wait_time);

void show_num_right(uint8_t show_wait_time);

void show_num_left_ge(uint8_t ge);
void show_num_left_shi(uint8_t shi);
void show_num_right_ge(uint8_t ge);
void show_num_right_shi(uint8_t shi);

uint8_t wait_time_left = 10;
uint8_t wait_time_right = 5;
uint32_t up_down_color_mode = GREEN;
uint32_t left_right_color_mode = RED;

bool emergency_happen = false;
bool north_south_passage = false;
bool east_west_passage = false;


/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for upDownLight */
osThreadId_t upDownLightHandle;
const osThreadAttr_t upDownLight_attributes = {
  .name = "upDownLight",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for leftRightLight */
osThreadId_t leftRightLightHandle;
const osThreadAttr_t leftRightLight_attributes = {
  .name = "leftRightLight",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for upDownNum */
osThreadId_t upDownNumHandle;
const osThreadAttr_t upDownNum_attributes = {
  .name = "upDownNum",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for leftRightNum */
osThreadId_t leftRightNumHandle;
const osThreadAttr_t leftRightNum_attributes = {
  .name = "leftRightNum",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for keyTask */
osThreadId_t keyTaskHandle;
const osThreadAttr_t keyTask_attributes = {
  .name = "keyTask",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityLow,
};
/* Definitions for lightRefresh */
osThreadId_t lightRefreshHandle;
const osThreadAttr_t lightRefresh_attributes = {
  .name = "lightRefresh",
  .stack_size = 256 * 4,
  .priority = (osPriority_t) osPriorityHigh,
};
/* Definitions for lvglTask */
osThreadId_t lvglTaskHandle;
const osThreadAttr_t lvglTask_attributes = {
  .name = "lvglTask",
  .stack_size = 1024 * 4,
  .priority = (osPriority_t) osPriorityLow,
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void UpDownLightTask(void *argument);
void LeftRightLightTask(void *argument);
void UpDownNumTask(void *argument);
void LeftRightNumTask(void *argument);
void KeyTask(void *argument);
void LightRefreshTask(void *argument);
void LvglTask(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
    /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
    /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
    /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
    /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of upDownLight */
  upDownLightHandle = osThreadNew(UpDownLightTask, NULL, &upDownLight_attributes);

  /* creation of leftRightLight */
  leftRightLightHandle = osThreadNew(LeftRightLightTask, NULL, &leftRightLight_attributes);

  /* creation of upDownNum */
  upDownNumHandle = osThreadNew(UpDownNumTask, NULL, &upDownNum_attributes);

  /* creation of leftRightNum */
  leftRightNumHandle = osThreadNew(LeftRightNumTask, NULL, &leftRightNum_attributes);

  /* creation of keyTask */
  keyTaskHandle = osThreadNew(KeyTask, NULL, &keyTask_attributes);

  /* creation of lightRefresh */
  lightRefreshHandle = osThreadNew(LightRefreshTask, NULL, &lightRefresh_attributes);

  /* creation of lvglTask */
  lvglTaskHandle = osThreadNew(LvglTask, NULL, &lvglTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
    /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
    /* add events, ... */
    /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_UpDownLightTask */
/**
  * @brief  Function implementing the upDownLight thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_UpDownLightTask */
void UpDownLightTask(void *argument)
{
  /* USER CODE BEGIN UpDownLightTask */
    /* Infinite loop */
    for (;;) {
        up_down_color_mode = GREEN;
        osDelay(1000 * wait_time_left);
        for (int i = 0; i < 3; ++i) {
            up_down_color_mode = YELLOW;
            osDelay(500);
            up_down_color_mode = WHITE;
            osDelay(500);
        }
        up_down_color_mode = RED;
        osDelay(1000 * (wait_time_right + 3));
    }
  /* USER CODE END UpDownLightTask */
}

/* USER CODE BEGIN Header_LeftRightLightTask */
/**
* @brief Function implementing the leftRightLight thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LeftRightLightTask */
void LeftRightLightTask(void *argument)
{
  /* USER CODE BEGIN LeftRightLightTask */
    /* Infinite loop */
    for (;;) {
        left_right_color_mode = RED;
        osDelay(1000 * (wait_time_left + 3));
        left_right_color_mode = GREEN;
        osDelay(1000 * wait_time_right);
        for (int i = 0; i < 3; ++i) {
            left_right_color_mode = YELLOW;
            osDelay(500);
            left_right_color_mode = WHITE;
            osDelay(500);
        }
    }
  /* USER CODE END LeftRightLightTask */
}

/* USER CODE BEGIN Header_UpDownNumTask */
/**
* @brief Function implementing the upDownNum thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_UpDownNumTask */
void UpDownNumTask(void *argument)
{
  /* USER CODE BEGIN UpDownNumTask */
    g_point_color = WHITE;    /* 画笔颜色 */
    g_back_color = BLACK;    /* 背景颜色 */
    uint8_t show_wait_time;
    show_wait_time = wait_time_left;
    uint32_t color_mode;
    color_mode = GREEN;
    /* Infinite loop */
    for (;;) {
        if (emergency_happen == false) {
            show_num_left(show_wait_time);
        } else {
            show_num_left(0);
        }
        show_wait_time--;
        osDelay(1000);

        if ((show_wait_time == 0) && (color_mode == GREEN)) {
            show_wait_time = 3;
            color_mode = YELLOW;
        }
        if ((show_wait_time == 0) && (color_mode == YELLOW)) {
            show_wait_time = wait_time_right + 3;
            color_mode = RED;
        }
        if ((show_wait_time == 0) && (color_mode == RED)) {
            show_wait_time = wait_time_left;
            color_mode = GREEN;
        }
    }
  /* USER CODE END UpDownNumTask */
}

/* USER CODE BEGIN Header_LeftRightNumTask */
/**
* @brief Function implementing the leftRightNum thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LeftRightNumTask */
void LeftRightNumTask(void *argument)
{
  /* USER CODE BEGIN LeftRightNumTask */
    g_point_color = WHITE;    /* 画笔颜色 */
    g_back_color = BLACK;    /* 背景颜色 */
    uint8_t show_wait_time;
    show_wait_time = wait_time_left + 3;
    uint32_t color_mode;
    color_mode = RED;
    /* Infinite loop */
    for (;;) {
        if (emergency_happen == false) {
            show_num_right(show_wait_time);
        } else {
            show_num_right(0);
        }
        show_wait_time--;
        osDelay(1000);

        if ((show_wait_time == 0) && (color_mode == RED)) {
            show_wait_time = wait_time_right;
            color_mode = GREEN;
        }
        if ((show_wait_time == 0) && (color_mode == GREEN)) {
            show_wait_time = 3;
            color_mode = YELLOW;
        }
        if ((show_wait_time == 0) && (color_mode == YELLOW)) {
            show_wait_time = wait_time_left + 3;
            color_mode = RED;
        }
    }
  /* USER CODE END LeftRightNumTask */
}

/* USER CODE BEGIN Header_KeyTask */
/**
* @brief Function implementing the keyTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_KeyTask */
void KeyTask(void *argument)
{
  /* USER CODE BEGIN KeyTask */
    /* Infinite loop */
    for (;;) {
        if (key_up_pressed) {
            wait_time_left++;
            if (wait_time_left == 100) {
                wait_time_left = 99;
            }
            lv_label_set_text_fmt(ui_LabelPassTime, "%d\n%d",
                                  wait_time_left, wait_time_right);
            key_up_pressed = false;
        }
        if (key_down_pressed) {
            wait_time_left--;
            if (wait_time_left == 0) {
                wait_time_left = 1;
            }
            lv_label_set_text_fmt(ui_LabelPassTime, "%d\n%d",
                                  wait_time_left, wait_time_right);
            key_down_pressed = false;
        }
        if (key_left_pressed) {
            if (wait_time_right > 1) {
                wait_time_right--;
            }
            lv_label_set_text_fmt(ui_LabelPassTime, "%d\n%d",
                                  wait_time_left, wait_time_right);
            key_left_pressed = false;
        }
        if (key_right_pressed) {
            if (wait_time_right < 100) {
                wait_time_right++;
            }
            lv_label_set_text_fmt(ui_LabelPassTime, "%d\n%d",
                                  wait_time_left, wait_time_right);
            key_right_pressed = false;
        }
        osDelay(300);
    }
  /* USER CODE END KeyTask */
}

/* USER CODE BEGIN Header_LightRefreshTask */
/**
* @brief Function implementing the lightRefresh thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LightRefreshTask */
void LightRefreshTask(void *argument)
{
  /* USER CODE BEGIN LightRefreshTask */
    /* Infinite loop */
    for (;;) {
        light_left_show_color_with_emergency(up_down_color_mode);
        light_right_show_color_with_emergency(left_right_color_mode);
        osDelay(500);
    }
  /* USER CODE END LightRefreshTask */
}

/* USER CODE BEGIN Header_LvglTask */
/**
* @brief Function implementing the lvglTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LvglTask */
void LvglTask(void *argument)
{
  /* USER CODE BEGIN LvglTask */
    /* Infinite loop */
    for (;;) {

        lv_label_set_text_fmt(ui_LabelPassTime, "%d\n%d",
                              wait_time_left, wait_time_right);
        lv_timer_handler();
        osDelay(5);
    }
  /* USER CODE END LvglTask */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
void light_left_show_color(uint32_t color) {
    switch (color) {
        case GREEN:
            lv_obj_add_flag(ui_ImageLeftGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case RED:
            lv_obj_clear_flag(ui_ImageLeftGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(ui_ImageLeftRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case YELLOW:
            lv_obj_clear_flag(ui_ImageLeftGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(ui_ImageLeftYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case WHITE:
            lv_obj_clear_flag(ui_ImageLeftGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageLeftRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        default:
            break;
    }
}


void light_right_show_color(uint32_t color) {
    switch (color) {
        case GREEN:
            lv_obj_add_flag(ui_ImageRightGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case RED:
            lv_obj_clear_flag(ui_ImageRightGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(ui_ImageRightRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case YELLOW:
            lv_obj_clear_flag(ui_ImageRightGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(ui_ImageRightYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        case WHITE:
            lv_obj_clear_flag(ui_ImageRightGreenClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightYellowClose, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(ui_ImageRightRedClose, LV_OBJ_FLAG_HIDDEN);
            break;
        default:
            break;
    }
}


void light_left_show_color_with_emergency(uint32_t color) {
    if (emergency_happen) {
        if (north_south_passage) {
            light_left_show_color(GREEN);
        } else if (east_west_passage) {
            light_left_show_color(RED);
        }
    } else {
        light_left_show_color(color);
    }

}

void light_right_show_color_with_emergency(uint32_t color) {
    if (emergency_happen) {
        if (north_south_passage) {
            light_right_show_color(RED);
        } else if (east_west_passage) {
            light_right_show_color(GREEN);
        }
    } else {
        light_right_show_color(color);
    }
}

void show_num_left(uint8_t show_wait_time) {
    show_num_left_ge(show_wait_time % 10);
    show_num_left_shi(show_wait_time / 10);
}

void show_num_right(uint8_t show_wait_time) {
    show_num_right_ge(show_wait_time % 10);
    show_num_right_shi(show_wait_time / 10);
}

void show_num_left_ge(uint8_t ge) {
    lv_obj_add_flag(ui_ImageLeftGe0, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe1, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe2, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe3, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe4, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe5, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe6, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe7, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe8, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftGe9, LV_OBJ_FLAG_HIDDEN);
    switch (ge) {
        case 0: lv_obj_clear_flag(ui_ImageLeftGe0, LV_OBJ_FLAG_HIDDEN); break;
        case 1: lv_obj_clear_flag(ui_ImageLeftGe1, LV_OBJ_FLAG_HIDDEN); break;
        case 2: lv_obj_clear_flag(ui_ImageLeftGe2, LV_OBJ_FLAG_HIDDEN); break;
        case 3: lv_obj_clear_flag(ui_ImageLeftGe3, LV_OBJ_FLAG_HIDDEN); break;
        case 4: lv_obj_clear_flag(ui_ImageLeftGe4, LV_OBJ_FLAG_HIDDEN); break;
        case 5: lv_obj_clear_flag(ui_ImageLeftGe5, LV_OBJ_FLAG_HIDDEN); break;
        case 6: lv_obj_clear_flag(ui_ImageLeftGe6, LV_OBJ_FLAG_HIDDEN); break;
        case 7: lv_obj_clear_flag(ui_ImageLeftGe7, LV_OBJ_FLAG_HIDDEN); break;
        case 8: lv_obj_clear_flag(ui_ImageLeftGe8, LV_OBJ_FLAG_HIDDEN); break;
        case 9: lv_obj_clear_flag(ui_ImageLeftGe9, LV_OBJ_FLAG_HIDDEN); break;
        default: break;
    }
}

void show_num_left_shi(uint8_t shi) {
    lv_obj_add_flag(ui_ImageLeftShi0, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi1, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi2, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi3, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi4, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi5, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi6, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi7, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi8, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageLeftShi9, LV_OBJ_FLAG_HIDDEN);
    switch (shi) {
        case 0: lv_obj_clear_flag(ui_ImageLeftShi0, LV_OBJ_FLAG_HIDDEN); break;
        case 1: lv_obj_clear_flag(ui_ImageLeftShi1, LV_OBJ_FLAG_HIDDEN); break;
        case 2: lv_obj_clear_flag(ui_ImageLeftShi2, LV_OBJ_FLAG_HIDDEN); break;
        case 3: lv_obj_clear_flag(ui_ImageLeftShi3, LV_OBJ_FLAG_HIDDEN); break;
        case 4: lv_obj_clear_flag(ui_ImageLeftShi4, LV_OBJ_FLAG_HIDDEN); break;
        case 5: lv_obj_clear_flag(ui_ImageLeftShi5, LV_OBJ_FLAG_HIDDEN); break;
        case 6: lv_obj_clear_flag(ui_ImageLeftShi6, LV_OBJ_FLAG_HIDDEN); break;
        case 7: lv_obj_clear_flag(ui_ImageLeftShi7, LV_OBJ_FLAG_HIDDEN); break;
        case 8: lv_obj_clear_flag(ui_ImageLeftShi8, LV_OBJ_FLAG_HIDDEN); break;
        case 9: lv_obj_clear_flag(ui_ImageLeftShi9, LV_OBJ_FLAG_HIDDEN); break;
        default: break;
    }
}

void show_num_right_ge(uint8_t ge) {
    lv_obj_add_flag(ui_ImageRightGe0, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe1, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe2, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe3, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe4, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe5, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe6, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe7, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe8, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightGe9, LV_OBJ_FLAG_HIDDEN);
    switch (ge) {
        case 0: lv_obj_clear_flag(ui_ImageRightGe0, LV_OBJ_FLAG_HIDDEN); break;
        case 1: lv_obj_clear_flag(ui_ImageRightGe1, LV_OBJ_FLAG_HIDDEN); break;
        case 2: lv_obj_clear_flag(ui_ImageRightGe2, LV_OBJ_FLAG_HIDDEN); break;
        case 3: lv_obj_clear_flag(ui_ImageRightGe3, LV_OBJ_FLAG_HIDDEN); break;
        case 4: lv_obj_clear_flag(ui_ImageRightGe4, LV_OBJ_FLAG_HIDDEN); break;
        case 5: lv_obj_clear_flag(ui_ImageRightGe5, LV_OBJ_FLAG_HIDDEN); break;
        case 6: lv_obj_clear_flag(ui_ImageRightGe6, LV_OBJ_FLAG_HIDDEN); break;
        case 7: lv_obj_clear_flag(ui_ImageRightGe7, LV_OBJ_FLAG_HIDDEN); break;
        case 8: lv_obj_clear_flag(ui_ImageRightGe8, LV_OBJ_FLAG_HIDDEN); break;
        case 9: lv_obj_clear_flag(ui_ImageRightGe9, LV_OBJ_FLAG_HIDDEN); break;
        default: break;
    }
}

void show_num_right_shi(uint8_t shi) {
    lv_obj_add_flag(ui_ImageRightShi0, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi1, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi2, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi3, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi4, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi5, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi6, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi7, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi8, LV_OBJ_FLAG_HIDDEN);
    lv_obj_add_flag(ui_ImageRightShi9, LV_OBJ_FLAG_HIDDEN);
    switch (shi) {
        case 0: lv_obj_clear_flag(ui_ImageRightShi0, LV_OBJ_FLAG_HIDDEN); break;
        case 1: lv_obj_clear_flag(ui_ImageRightShi1, LV_OBJ_FLAG_HIDDEN); break;
        case 2: lv_obj_clear_flag(ui_ImageRightShi2, LV_OBJ_FLAG_HIDDEN); break;
        case 3: lv_obj_clear_flag(ui_ImageRightShi3, LV_OBJ_FLAG_HIDDEN); break;
        case 4: lv_obj_clear_flag(ui_ImageRightShi4, LV_OBJ_FLAG_HIDDEN); break;
        case 5: lv_obj_clear_flag(ui_ImageRightShi5, LV_OBJ_FLAG_HIDDEN); break;
        case 6: lv_obj_clear_flag(ui_ImageRightShi6, LV_OBJ_FLAG_HIDDEN); break;
        case 7: lv_obj_clear_flag(ui_ImageRightShi7, LV_OBJ_FLAG_HIDDEN); break;
        case 8: lv_obj_clear_flag(ui_ImageRightShi8, LV_OBJ_FLAG_HIDDEN); break;
        case 9: lv_obj_clear_flag(ui_ImageRightShi9, LV_OBJ_FLAG_HIDDEN); break;
        default: break;
    }
}
/* USER CODE END Application */

